package com.cw.jeeyt.service.converter.api;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.api.ApiFacadeObjEnumBo;
import com.cw.jeeyt.dao.model.api.ApiFacadeObjEnumDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 枚举对象信息转换类
 *
 * @author chenw
 * @date 2019-03-10 13:05:36
 */
public class ApiFacadeObjEnumConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ApiFacadeObjEnumBo do2Bo(ApiFacadeObjEnumDo model) {
        if (model == null) {
            return null;
        }
        ApiFacadeObjEnumBo bo = new ApiFacadeObjEnumBo();
        bo.setId(model.getId());
        bo.setParentId(model.getParentId());
        bo.setEnumCode(model.getEnumCode());
        bo.setEnumName(model.getEnumName());
        bo.setEnumPackage(model.getEnumPackage());
        bo.setEnumComment(model.getEnumComment());
        bo.setEnumItemCode(model.getEnumItemCode());
        bo.setEnumItemKey(model.getEnumItemKey());
        bo.setEnumItemDesc(model.getEnumItemDesc());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ApiFacadeObjEnumDo bo2Do(ApiFacadeObjEnumBo bo) {
        if (bo == null) {
            return null;
        }
        ApiFacadeObjEnumDo model = new ApiFacadeObjEnumDo();
        model.setId(bo.getId());
        model.setParentId(bo.getParentId());
        model.setEnumCode(bo.getEnumCode());
        model.setEnumName(bo.getEnumName());
        model.setEnumPackage(bo.getEnumPackage());
        model.setEnumComment(bo.getEnumComment());
        model.setEnumItemCode(bo.getEnumItemCode());
        model.setEnumItemKey(bo.getEnumItemKey());
        model.setEnumItemDesc(bo.getEnumItemDesc());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ApiFacadeObjEnumBo> doList2BoList(List<ApiFacadeObjEnumDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ApiFacadeObjEnumConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ApiFacadeObjEnumDo> boList2DoList(List<ApiFacadeObjEnumBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ApiFacadeObjEnumConverter::bo2Do));
    }
}